home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9825 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: seagull.rtd.com!collins
  2. From: collins@RTD.COM (Ronald Collins)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Standard question - pointer initialization
  5. Date: 13 Mar 1996 20:59:26 GMT
  6. Organization: RTD Internet Access
  7. Message-ID: <4i7cve$5da@baygull.rtd.com>
  8. References: <4hk9un$906@hammer.msfc.nasa.gov> <4hl6rr$nde@news.xs4all.nl> <313E6028.1C19@ix.netcom.com> <4hnpsl$g8c@hacgate2.hac.com> <4hq9hsINN998@keats.ugrad.cs.ubc.ca> <4i7cgn$5da@baygull.rtd.com>
  9. NNTP-Posting-Host: seagull.rtd.com
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Ronald Collins (collins@RTD.COM) wrote:
  13. : Kazimir Kylheku (c2a192@ugrad.cs.ubc.ca) wrote:
  14.  
  15. : : Also note that NULL is just a macro that stands for the value zero (often
  16. : : accompanied by a cast to void *). In assigning default initialization values to
  17. : : static variables, the compiler couldn't care less that there is a pre-processor
  18. : : macro called NULL. NULL can never be anything other than zero in a
  19. : : standard-conforming implementation of the C language.
  20.  
  21. : This may be true on _your_ implementation, but nothing in the standard
  22. : requires the NULL value to be numerically 0.
  23.  
  24. : Please read the FAQ before posting on the subject again.
  25.  
  26. :         -- collins --
  27.  
  28. To follow-up on my own post ... the standard requires a zero to be
  29. used as NULL _only_ when the literal "0" is used.  A variable set to
  30. 0 (as in "int var = 0;") then cast to a pointer (as in "*p = (char *) var")
  31. is _not_ required to convert to a NULL.
  32.  
  33. If, above, you were talking about a literal "0", then I withdraw my comments.
  34. If you were talking of any numeric 0 value casting to a NULL, then my
  35. comments stand.
  36.  
  37.             -- collins --
  38.  
  39.